Skip to content

Add shift range text selection #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

MoeidHeidari
Copy link

Description

Implements shift+click selection behavior in the terminal to allow extending selections from the current cursor position or existing selection.

Related Issue

Closes #205

Changes Made

  • Added new SelectionMode.shift enum value to support shift+click selection behavior
  • Implemented shift+click selection handling in TerminalGestureHandler
  • Added keyboard event handling for shift key state tracking
  • Improved selection direction handling to maintain consistent selection direction when extending selections
  • Added proper handling of cursor position when no selection exists

Technical Details

  • Added shift key state tracking using HardwareKeyboard events
  • Implemented selection extension logic that:
    • Uses cursor position as anchor when no selection exists
    • Uses existing selection's start point as anchor when extending
    • Maintains selection direction (forward/reverse) when extending
  • Added proper handling of selection modes (line, block, shift) in the gesture handler

Testing

  • Tested shift+click selection with:
    • No existing selection (uses cursor position)
    • Existing selection (extends from selection start)
    • Different selection directions (forward/reverse)
    • Different selection modes (line/block)
  • Verified selection behavior with:
    • Single clicks
    • Drag operations
    • Long press operations

Additional Notes

  • No breaking changes
  • Improves user experience by making text selection more intuitive
  • Follows common terminal selection behavior patterns

@MoeidHeidari
Copy link
Author

No update?

@xtyxtyx xtyxtyx self-assigned this Jun 12, 2025
@MoeidHeidari
Copy link
Author

I think the last commit should fix the issue in GitHub actions

@xtyxtyx
Copy link
Member

xtyxtyx commented Jun 21, 2025

Hi, first really thanks for your interest and effort in contributing to the project.

However while the code works, it has much room for improvement. For example most of the core logic in this PR is placed in a utility class TerminalGestureHandler, and the BufferRangeShift class is introduced without clear semantics.

If the code is generated by AI, please guide the AI to generate better-structured code and review it in person before submitting the PR.

Thanks!

@MoeidHeidari
Copy link
Author

Thanks for the review

but I think if any part of the code has any semantic issue it was better if you would just comment on the code lines for me to fix instead of call it AI generated code when I spent hours to do an improvement and contribute.

Any way thanks for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Shift-Click Selection Support for Terminal Text
2 participants